const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebackPlugin = require('clean-webpack-plugin');
const VueLoaderPlugin=require('vue-loader/lib/plugin');
module.exports = {
    entry: './index.js',
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.scss$/,
                use: ['style-loader', 'css-loader', 'sass-loader']
            },{
                test: /\.vue$/,
                use:['vue-loader']
            }
        ]
    },
    output: {
        filename: "pack.[hash].js",
        path: path.resolve(__dirname, './dist'),
    },
    plugins: [
        new VueLoaderPlugin(),
        new htmlWebpackPlugin({
            template: "./index.html",
            inject: true

        }),
        new CleanWebackPlugin({
            dry:false,
            cleanOnceBeforeBuildPatterns:'./dist'
        })
    ],
    devServer: {
        //本地地址http://localhost:8080
        port: 8082,//端口号
        open: true,//是否自动打开浏览器
        hot: true//是否自动刷新浏览器
    },
    watch: true,
    watchOptions: {
        ignored: ['/node_modules/','/.idea/']
    }


};
